app_family.controller("controller_myfamily", function($scope, $rootScope, httpRequest, $location) {
	$rootScope.$broadcast('currentModule', 'controller_myfamily');
	$rootScope.$broadcast('footerFlag', false); // 是否显示底部导航
	$scope.imagebasepath = imagebasepath;
	
	/**
	 * 判断是否用手机登录过
	 */
	if (sessionStorage.getItem('data_sessionStorage')) {
		var familyPhone = JSON.parse(sessionStorage.getItem('data_sessionStorage')).familyInfo.phone;
		if (familyPhone == '' || familyPhone == null) {
			window.location.replace(basepath + 'login.html');
			return;
		}
	} else {
		window.location.replace(basepath + 'login.html');
		return;
	}
	
	/**
	 * 获取列表 若未绑定，跳往绑定页面
	 */
	httpRequest.getAllOlder({
		mobile : familyPhone
	}, function (data) {
		if (data.success === true) {
			$scope.familyList = data.obj;
			// 未绑定 跳转到绑定页面
			if (data.obj.length == 0) {
				$.dialog.showDialog({
					msgTxt : '您还没有绑定，现在去绑定一位吧~',
					isShowBtnCancel : false,
					callbackOk : function () {
						// 记录从哪个页面跳转到绑定页面
				    	data_sessionStorage = JSON.parse(sessionStorage.getItem('data_sessionStorage'));
				    	data_sessionStorage.record_page.page_bind.from = '/myfamily';
				    	sessionStorage.setItem('data_sessionStorage', JSON.stringify(data_sessionStorage));
				    	
						$location.path('/bind');
						$scope.$apply();
					}
				});
			}
		} else if (data.success === false) {
			$.dialog.showToast({msgTxt : data.msg});
		}
	});
	
	/**
     * 去绑定
     */
    $scope.gotoBind = function () {
    	// 记录从哪个页面跳转到绑定页面
    	data_sessionStorage = JSON.parse(sessionStorage.getItem('data_sessionStorage'));
    	data_sessionStorage.record_page.page_bind.from = '/addmessage';
    	sessionStorage.setItem('data_sessionStorage', JSON.stringify(data_sessionStorage));
    	
    	$location.path('/bind');
    	$scope.$apply();
    };
    
    /**
     * 查看日常信息数据
     */
    $scope.openfamilydata = function (account, user_type) {
    	// 记录查询哪个的日常信息数据
    	data_sessionStorage = JSON.parse(sessionStorage.getItem('data_sessionStorage'));
    	data_sessionStorage.data_searchFamilyInfo.older_account = account;
    	data_sessionStorage.data_searchFamilyInfo.user_type = user_type;
    	sessionStorage.setItem('data_sessionStorage', JSON.stringify(data_sessionStorage));
    	
    	$location.path('/familydata');
    	$scope.$apply();
    };
});